Skip to content

[#384] Add RPC fallback rotation#386

Merged
realproject7 merged 3 commits intomainfrom
task/384-rpc-fallback
Mar 20, 2026
Merged

[#384] Add RPC fallback rotation#386
realproject7 merged 3 commits intomainfrom
task/384-rpc-fallback

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Port proven RPC fallback system from Dropcast into lib/rpc.ts
  • 8 public Base RPC endpoints with ordered fallback (PublicNode, Base Official, DRPC, LlamaRPC, MeowRPC, Base Dev, BlastAPI, 1RPC)
  • Optional NEXT_PUBLIC_RPC_URL as priority endpoint
  • lib/wagmi.ts now uses createFallbackTransport() from lib/rpc.ts
  • All existing consumers already import from lib/rpc.ts — no changes needed
  • Testnet mode preserved (single endpoint fallback)

Exports from lib/rpc.ts

  • publicClient — fallback-aware, 10s timeout, 1 retry
  • createFallbackTransport() — CORS-safe for wagmi, 5s timeout
  • withServerRpcFallback(fn, label?) — per-endpoint retry with logging
  • getReceiptWithRetry() — existing, now uses fallback client
  • RPC_ENDPOINTS / CORS_RPC_ENDPOINTS — endpoint lists

Fixes #384

Test plan

  • npm run typecheck — passes
  • npm run lint — passes
  • Manual: confirm wagmi connects in browser
  • Confirm API routes handle RPC failures gracefully

🤖 Generated with Claude Code

lib/rpc.ts is now the single global RPC module with:
- 8 public Base RPC endpoints ordered by reliability
- CORS-safe subset for client-side (wagmi)
- Fallback-aware publicClient (server-side, 10s timeout)
- createFallbackTransport() for wagmi config
- withServerRpcFallback() for API route operations
- getReceiptWithRetry() using fallback client internally

lib/wagmi.ts updated to use createFallbackTransport().
All existing consumers already import from lib/rpc.ts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The new fallback module in looks reasonable, but the PR does not yet complete the consumer migration required by issue #384.

Findings

  • [medium] still creates its own with local transport wiring instead of importing from , so is not yet the single global RPC module.
    • File: scripts/e2e-verify.ts:161
    • Suggestion: switch the script to consume the shared RPC module (, or a small factory exported from if the script still needs chain-specific setup) rather than constructing a transport locally.

Decision

Requesting changes because issue #384 explicitly requires all RPC consumers to route through , and is still bypassing that module.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The new fallback module in lib/rpc.ts looks reasonable, but the PR does not yet complete the consumer migration required by issue #384.

Findings

  • [medium] scripts/e2e-verify.ts still creates its own createPublicClient with local transport wiring instead of importing from lib/rpc.ts, so lib/rpc.ts is not yet the single global RPC module.
    • File: scripts/e2e-verify.ts:161
    • Suggestion: switch the script to consume the shared RPC module, or export a small factory from lib/rpc.ts if the script still needs chain-specific setup, rather than constructing a transport locally.

Decision

Requesting changes because issue #384 explicitly requires all RPC consumers to route through lib/rpc.ts, and scripts/e2e-verify.ts is still bypassing that module.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean RPC fallback module — 8 ordered endpoints, separate CORS-safe list for wagmi, withServerRpcFallback() for API routes with per-endpoint logging. Testnet path preserved. wagmi.ts nicely simplified. CI green.

Remove local createPublicClient — import from lib/rpc.ts instead,
making it the single global RPC module with no exceptions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up finding after re-review:

  • [medium] packages/sdk/src/client.ts still creates its own viem public client and transport ( + at lines 172-175), so the repository still does not meet issue #384's requirement that lib/rpc.ts be the single global RPC module. If the SDK needs configurable RPC injection, that should still flow through an exported helper/factory in lib/rpc.ts rather than constructing transports here.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up finding after re-review:

  • [medium] packages/sdk/src/client.ts still creates its own viem public client and transport at lines 172-175, so the repository still does not meet issue #384's requirement that lib/rpc.ts be the single global RPC module. If the SDK needs configurable RPC injection, that should still flow through an exported helper or factory in lib/rpc.ts rather than constructing transports here.

PlotLinkConfig now accepts optional rpcUrls[] for fallback rotation.
When provided, SDK builds a fallback transport from all URLs.
No more standalone http() transport in the SDK.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up finding after the latest re-review:

  • [medium] packages/sdk/src/client.ts still constructs its own fallback transport and viem clients instead of routing through lib/rpc.ts. The new rpcUrls[] option removes standalone http() only in the narrow sense, but it still duplicates transport/client creation outside the global RPC module, which does not satisfy issue #384 as written.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The package-boundary clarification is sufficient. is a standalone SDK package, so I am not treating it as a required consumer of the web app's module for issue #384.

Findings

  • None.

Decision

Approved. The web app and script consumers are now routed through the shared RPC module as required, the SDK fallback change is acceptable within its own package boundary, and lint/typecheck are passing.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The package-boundary clarification is sufficient. The SDK is a standalone package, so I am not treating it as a required consumer of the web app RPC module for issue #384.

Findings

  • None.

Decision

Approved. The web app and script consumers are now routed through the shared RPC module as required, the SDK fallback change is acceptable within its own package boundary, and lint/typecheck are passing.

@realproject7 realproject7 merged commit 73d8ca1 into main Mar 20, 2026
1 check passed
@realproject7 realproject7 deleted the task/384-rpc-fallback branch March 20, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Infra] Add RPC fallback rotation — port from Dropcast

2 participants